<style lang="scss" scoped>

</style>

<template>
    <div class="infobody">
        <div class="topbar">
            <span class="leftbtn" @click="goback"><Icon type="ios-arrow-back"></Icon></span>
            <span class="centertitle">预付款</span>    
            <span class="rightbtn" @click="save">保存</span>  
        </div>
        <div class="content">
            <p class="form-title">预付款</p>
            <div class="info">
                <Form :model="moneyInfo" >
                    <FormItem  label="经销商" >
                        <Select :disabled="status"  v-model="moneyInfo.id" clearable placeholder="请选择经销商" >
                            <Option v-for="item in agentList" :value="item.id" :key="item.id" :label="item.agentName "></Option>
                        </Select>
                    </FormItem>
                    <FormItem  label="金额" >
                        <Input :disabled="status"  v-model="moneyInfo.payment" placeholder="请输入金额" number/>
                    </FormItem>
                </Form>
            </div>
        </div>        
    </div>
</template>

<script>
import {sampleData} from 'api/index.js'
export default {
    data(){
        return{
            status:false,
            agentList:[],
            moneyInfo:{
                id:'1',
                payment:''
            }
        }
    },
    methods: {
        goback(){
            this.$router.go(-1)
        },
        save(){
            let obj=this.moneyInfo;
            sampleData.paymentAdd(obj).then(res=>{
                if(res.code==0||res.code==200){
                    this.$Message.success("保存成功");
                    this.$router.push('/index')
                }else{
                    this.$Message.error(res.msg)
                }
            }).catch(error=>{
                this.$Message.error(error)
            })
        },
        getAgentListByUserId(){
            let obj={}
            sampleData.getAgentListByUserId(obj).then(res=>{
                if (res.code == 0 || res.code == 200) {
                this.agentList=res.list;
                }       
            }).catch(error=>{
                this.$Message.error(error)
            })
        } 
    },
    mounted() {
        this.getAgentListByUserId();
    },
}
</script>


